﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tilver.ExceptionHandling
{
    /// <summary>
    /// 异常类的扩展方法
    /// </summary>
    public static class ExceptionExtensions
    {
        /// <summary>
        /// 添加用户自定义数据，key默认使用ex.Data的当前索引加1
        /// </summary>
        /// <param name="ex">引发的异常对象</param>
        /// <param name="data">自定义数据</param>
        public static void AddUserData(this Exception ex, object data)
        {
            if (ex.Data != null)
            {
                ex.Data.Add(ex.Data.Count, data);
            }
        }

    }
}
